//
//  SignUpStep4ViewController.swift
//  FridgeSolo
//
//  Created by LiuXing on 2017/6/11.
//  Copyright © 2017年 kumi.com. All rights reserved.
//

import UIKit

class UserAccount: NSObject, NSCoding {
    // MARK: - 属性
    var tall: String?
    var weight: String?
    var goalWeight: String?
    var gender: String?
    var birthday: String?
    var weeklyGoal: String?
    
    var email: String?
    var password: String?
    
    // 自定义
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeys(dict)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
    }
    
    // MARK: - 重写
    override var description: String {
//        return dictionaryWithValues(forKeys: ["address", "age", "authorize", "birthday", "email", "id", "industry", "nickname", "occupation", "phoneNum", "remainLicenseDays", "sex"]).description
        return "12121"
    }
    
    // 归档
    func encode(with aCoder: NSCoder) {
        aCoder.encode(tall, forKey: "tall")
        aCoder.encode(weight, forKey: "weight")
        aCoder.encode(goalWeight, forKey: "goalWeight")
        aCoder.encode(gender, forKey: "gender")
        aCoder.encode(birthday, forKey: "birthday")
        aCoder.encode(weeklyGoal, forKey: "weeklyGoal")
        aCoder.encode(email, forKey: "email")
        aCoder.encode(password, forKey: "password")
    }
    // 解档
    required init?(coder aDecoder: NSCoder) {
        super.init()
        tall = aDecoder.decodeObject(forKey: "tall") as? String
        weight = aDecoder.decodeObject(forKey: "weight") as? String
        goalWeight = aDecoder.decodeObject(forKey: "goalWeight") as? String
        birthday = aDecoder.decodeObject(forKey: "birthday") as? String
        gender = aDecoder.decodeObject(forKey: "gender") as? String
        birthday = aDecoder.decodeObject(forKey: "birthday") as? String
        weeklyGoal = aDecoder.decodeObject(forKey: "weeklyGoal") as? String
        
        email = aDecoder.decodeObject(forKey: "email") as? String
        password = aDecoder.decodeObject(forKey: "password") as? String
    }
}
